package org.iwidget.desktop.core;
import org.iwidget.desktop.model.ElementPreferences;
import org.iwidget.desktop.model.WidgetElement;
/**
 *
 * @author Muhammad Hakim A
 */


public class IwidgetWidgetPreferences
{

    public IwidgetWidgetPreferences(WidgetElement widget)
    {
        this.widget = widget;
    }

    public Object get(String preferenceName)
    {
        for(int iCtr = 0; iCtr < widget.getPreferenceObjects().size(); iCtr++)
        {
            ElementPreferences pref = (ElementPreferences)widget.getPreferenceObjects().get(iCtr);
            if(pref.getName().equals(preferenceName))
                return pref.getValue();
        }

        return null;
    }

    public void set(String preferenceName, Object value)
    {
        for(int iCtr = 0; iCtr < widget.getPreferenceObjects().size(); iCtr++)
        {
            ElementPreferences pref = (ElementPreferences)widget.getPreferenceObjects().get(iCtr);
            if(pref.getName().equals(preferenceName))
                pref.setValue((String)value);
        }

    }

    private WidgetElement widget;
}